/*
 * GLSoulSpirit.h
 *
 *  Created on: Nov 28, 2014
 *      Author: yuliang
 */

#ifndef GLSOULSPIRIT_H_
#define GLSOULSPIRIT_H_

#include "LogicBase/GLContainerBase.h"
#include "GLGoodsProperty.h"
#include "logic/LogicConfig.h"

class CGLSoulSpirit: public CGLContainerBase {
public:
	CGLSoulSpirit(const UserId_t& uid);
	virtual ~CGLSoulSpirit();

	virtual bool DecodeContainerExtend(const std::string& info);
	virtual bool EncodeContainerExtend(std::string& info);
	virtual bool DecodeGoodsExtend(uint8_t box, Index_t index, const std::string& info);
	virtual bool EncodeGoodsExtend(CGLGoodsBase*, std::string& info);

	virtual inline void Reset();

	inline EntityQuatityModel AddLev();
	inline EntityQuatityModel GetLev() const { return m_Lev; }
	inline float GetRate() const { return m_Rate; }
protected:
	// 新建物品,并初始化
	virtual CGLGoodsBase* getGoods();
	virtual void setGoods(CGLGoodsBase* goods);
	virtual const GoodsFixInfo* getGoodsFixInfo(Type_t type) const;
private:
	EntityQuatityModel			m_Lev;
	float						m_Rate;
};

void
CGLSoulSpirit::Reset() {
	m_Lev = QuatityType_1;
	m_Rate = *CLogicConfig::GetInstance()->GetSoulRate(m_Lev);
}

EntityQuatityModel
CGLSoulSpirit::AddLev() {
	m_Lev = EntityQuatityModel(m_Lev + 1);
	m_Rate = *CLogicConfig::GetInstance()->GetSoulRate(m_Lev);
	return m_Lev;
}

#endif /* GLSOULSPIRIT_H_ */
